package high.concurrent.pay.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 微信的参数配置
 * 接口文档：https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/index.shtml  -->NATIVE支付
 *
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "pay.wechat")
public class WechatPayConfig {

    /**
     * 商户号
     */
    private String mchId;

    /**
     * AppID
     */
    private String wxPayAppid;

    /**
     * 商户证书序列号，需要和证书对应
     */
    private String mchSerialNo;

    /**
     * API V3密钥, 32位的大小写字母，就是自己生成32位，并配置到微信那里，但项目里要用生成好并配置到微信的32位，不可自己现生成
     */
    private String apiV3Key;

    /**
     * 商户私钥路径, 暂时放到项目里的resource/cert下(微信服务端会根据证书序列号，找到证书获取公钥进行解密数据)
     */
    private String privateKeyPath;

    /**
     * 支付成功页面跳转
     */
    private String successReturnUrl;

    /**
     * 支付成功回调通知
     */
    private String callbackUrl;

    public static class Url{

        /**
         * native支付下单（POST）
         * https://api.mch.weixin.qq.com/v3/pay/transactions/native
         */
        public static final String NATIVE_ORDER = "https://api.mch.weixin.qq.com/v3/pay/transactions/native";
        /**
         * sign用到
         */
        public static final String NATIVE_ORDER_PATH = "/v3/pay/transactions/native";

        /**
         * native订单查询接口，根据商户订单号(自己生成的) + 商户号（GET）
         * https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}
         */
        public static final String NATIVE_QUEUE = "https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/%s?mchid=%s";
        public static final String NATIVE_QUEUE_PATH = "/v3/pay/transactions/out-trade-no/%s?mchId=%s";

        /**
         * native关单接口(POST)
         * https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/{out_trade_no}/close
         */
        public static final String NATIVE_CLOSE = "https://api.mch.weixin.qq.com/v3/pay/transactions/out-trade-no/%s/close";
        public static final String NATIVE_CLOSE_PATH = "/v3/pay/transactions/out-trade-no/%s/close";

        /**
         * native退款(POST)
         */
        public static final String NATIVE_REFUND = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds";
        public static final String NATIVE_REFUND_ORDER = "/v3/refund/domestic/refunds";


        /**
         * native退款状态查询(GET)
         */
        public static final String NATIVE_QUEUE_REFUND = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/%s";
        public static final String NATIVE_QUEUE_REFUND_ORDER = "/v3/refund/domestic/refunds/%s";
    }


}
